package interlocking.ui;

import interlocking.controller.InterlockingController;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainWindow extends JFrame{
    private InterlockingController controller;
    private StationPanel stationPanel;
    private ControlPanel controlPanel;

    public MainWindow(InterlockingController controller) {
        this.controller = controller;
        initializeUI();
    }

    private void initializeUI() {
        setTitle("计算机联锁模拟系统");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(1200, 800);
        setLayout(new BorderLayout());

        // 创建站场显示面板
        stationPanel = new StationPanel(controller);
        add(stationPanel, BorderLayout.CENTER);

        // 创建控制面板
        controlPanel = new ControlPanel(controller);
        add(controlPanel, BorderLayout.EAST);

        // 状态栏
        JLabel statusBar = new JLabel("系统就绪");
        add(statusBar, BorderLayout.SOUTH);
    }

    public void updateUI() {
        stationPanel.repaint();
        controlPanel.updateControls();
    }


}
